<?php
    App::import('Model', 'Family');


    class FamilyTestCase extends CakeTestCase {
        var $fixtures = array('app.family', 'app.event', 'app.events_family', 'app.person', 'app.families_person');
    
    	function testGetAllFamilies() {
    		$this->Family =& ClassRegistry::init('Family');
    		
    		$result = $this->Family->getAllFamilies();
    		$expected = array(1 => 'testFamily1', 2 => 'testFamily2');
    		
    		$this->assertEqual($result, $expected);
    		
    	}
    	
    	function testGetFamilyNames() {
    		$this->Family =& ClassRegistry::init('Family');
    		
    		$result = $this->Family->getFamilyNames(array(1, 2));
    		$expected = array(1 => 'testFamily1', 2 => 'testFamily2');
    		$this->assertEqual($result, $expected);
    	}
    	
    	function testGetFamilyName() {
    		$this->Family =& ClassRegistry::init('Family');
    		
    		$result = $this->Family->getFamilyName(1);
    		$expected = 'testFamily1';
    		$this->assertEqual($result, $expected);
    		
    		$result = $this->Family->getFamilyName(3);
    		$expected = null;
    		$this->assertEqual($result, $expected);
    		
    	}
    	
    	function testGetFamilyPersonAdminStatus() {
    		$this->Family =& ClassRegistry::init('Family');
    		
    		$result = $this->Family->getFamilyPersonAdminStatus(1);
    		$expected = array(1 => 1);
    		
    		$this->assertEqual($result, $expected);
    	}
    	
    	function testIsPersonFamilyAdmin() {
    		$this->Family =& ClassRegistry::init('Family');
    		
    		$result = $this->Family->isPersonFamilyAdmin(1, 1);
    		$this->assertTrue($result);
    		
    		$result = $this->Family->isPersonFamilyAdmin(2, 1);
    		$this->assertFalse($result);
    	}
    	
    	function testGetPeopleFromFamily() {
    		$this->Family =& ClassRegistry::init('Family');
    		
    		$result = $this->Family->getPeopleFromFamily(1);
    		$expected = array(1 => 1);
    		$this->assertEqual($result, $expected);
    	}
    
    	function testGetFamilyFromEID() {
    		$this->Family =& ClassRegistry::init('Family');
    		
    		$result = $this->Family->getFamilyFromID(1);
    		$expected = array(
			'id' => 1,
			'name' => 'testFamily1',
			'created' => '0000-00-00 00:00:00',
			'modified' => '0000-00-00 00:00:00'
			);
			
			$this->assertEqual($result, $expected);
    	}
    
        function testEventsFromFamilies() {
            $this->Family =& ClassRegistry::init('Family');
        
            // Testing empty input array
            $result = $this->Family->getEventsFromFamilies(array());
            $expected = array();
            $this->assertEqual($result, $expected);
            
            // Testing multiple return results
            $result = $this->Family->getEventsFromFamilies(array(1, 2));
            $expected = array(1, 2);
            $this->assertEqual($result, $expected);
            
            // Testing no return results
            $result = $this->Family->getEventsFromFamilies(array(2));
            $expected = array();
            $this->assertEqual($result, $expected);                        
        }
        
    }
 

?>
